<%@ page import="com.mulanweb.db.common.Constant" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/8/22
  Time: 11:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String openId = request.getSession().getAttribute("openId") + "";
%>
<!DOCTYPE html>
<html>
<head>
    <%--<meta http-equiv="Access-Control-Allow-Origin" content="open.weixin.qq.com">--%>
    <title>新途微助手</title>
    <%@include file="../../include/header.jsp" %>
    <style>
        a:hover, a:visited, a:active, a:link {
            text-decoration: none;
            color: black;
        }
    </style>
</head>
<body>
    <!-- Status bar overlay for full screen mode (PhoneGap) -->
    <div class="statusbar-overlay"></div>
    <!-- Panels overlay-->
    <div class="panel-overlay"></div>
    <!-- Views -->
    <div class="views">
        <!-- Your main view, should have "view-main" class -->
        <div class="view view-main">
            <!-- Top Navbar-->
            <div class="navbar">
                <div class="navbar-inner">
                    <!-- We need cool sliding animation on title element, so we have additional "sliding" class -->
                    <div class="left">
                        <a class="link" onClick="targetPage()" id="back"><i class="icon icon-back"></i><span>返回</span></a>
                    </div>
                    <div class="center sliding">支付页
                    </div>
                </div>
            </div>
            <!-- Pages container, because we use fixed-through navbar and toolbar, it has additional appropriate classes-->
            <div class="pages navbar-through toolbar-through">
                <div data-page="confirm_pay" class="page">
                    <!-- Scrollable page content -->
                    <div class="page-content">
                        <div style="height:1%"></div>
                        <input type="hidden" id="visaOrderTag" value="${param.visaOrderTag}" />
                        <div style="height:40px;padding-left:5%;line-height: 40px;font-size: 14px;color:#676767;background-color: white;border-bottom: 1px solid #E5E5E5">
                            <div style="width:4px;height:15px;background-color: #509AF1;float:left;margin-top:13px; margin-right: 5px"></div>
                            订单号：${param.orderNumber} </div>
                        <div class="list-block media-list inset "
                             style="margin:0px;margin-bottom: 5px;width:100%;height:110px;">
                            <ul style="border-radius: 0px;">
                                <li><a class="item-link item-content">
                                    <%--<div class="item-media">
                                        <img src="${photoPath}${param.targetLogo}" width="80">
                                    </div>--%>
                                        <div class="item-media" style="width:120px">
                                            <div style="width:80px;height:80px">
                                                <img src="${photoPath}${param.targetLogo}" style="display:block;height:100%;">
                                            </div>
                                        </div>
                                    <div class="item-inner">
                                        <div style="height:50px;width:100%;overflow:hidden">${param.title}</div>
                                        <div style="height:40px;width:100%;">
                                            <div style="height:10px"> </div>
                                            <img src="../../static/image/search/price-title-2x.png" width="37"/>
                                            <span style="color:#FF5B61;font-size:14px;font-weight: bold">￥${param.price}元/人</span>
                                        </div>
                                    </div>
                                </a></li>
                            </ul>
                        </div>
                        <div style="height:10%"></div>
                        <div style="text-align: center"><img src="../../static/image/pay/time.png" width="15"/>请在15分钟之内支付</div>
                        <div style="height:20px"></div>
                        <div><a class="button" id="toolbar-button" onclick="callpay('${param.orderNumber}')"
                                style="width:80%;margin-left: 10%;background-color:#509AF1;color:white;height:40px;line-height:40px;
                   border-radius:2px;">确认支付</a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="../../include/footer.jsp" %>
    <script>
        var myApp = new Framework7();
        var $$ = Framework7.$;
        var mainView = myApp.addView('.view-main');
        //关于为微信支付的方法
        function startPay(orderNumber) {
            var visaOrderTag = '${param.visaOrderTag}';
            var url = "${ctx}/mulanweb/wxpay/startRequest";
            if(visaOrderTag){
                url = "${ctx}/mulanweb/wxpay/startRequestVisaOrder";
            }
            var para ={
                orderNumber:orderNumber
            }
            $.ajax({
                url: url,
                async: false,
                type: "post",
                dataType: "json",
                data : para,
                success: function (data) {
                    App.hideLoading();
                    var obj = data.DataList;
                    if(obj){
                        WeixinJSBridge.invoke('getBrandWCPayRequest',{
                            "appId" : obj.appId,                  //公众号名称，由商户传入
                            "timeStamp":obj.timeStamp,          //时间戳，自 1970 年以来的秒数
                            "nonceStr" : obj.nonceStr,         //随机串
                            "package" : obj.packageValue,      //<span style="font-family:微软雅黑;">商品包信息</span>
                            "signType" : obj.signType,        //微信签名方式:
                            "paySign" : obj.paySign           //微信签名
                        },function(res){
                            if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                                $.post(Constant.contextUrl+obj.sendUrl,{},function(info){
                                    if(info.ReturnCode == 1){
                                        myApp.alert('新西兰微助手',"支付成功");
                                        window.location.href="<%=Constant.XinXiLan.PAY_SUCCESS_PAGE_URL%>";
                                    }else{
                                        myApp.alert('新西兰微助手',info.AlertMessage);
                                    }
                                })
                            }else{
                                alert("失败="+obj.sendUrl);
                                window.location.href="<%=Constant.XinXiLan.PAY_FAIL_PAGE_URL%>";
                                //<span style="font-family:微软雅黑;">当失败后，继续跳转该支付页面让用户可以继续付款，贴别注意不能直接调转jsp，</span><span style="font-size:10.5pt">不然会报</span><span style="font-size:12.0pt"> system:access_denied。</span>
                            }
                        })
                    }
                }
            });
        }

        function callpay(orderNumber)
        {
            App.showLoading();
            setTimeout(function(){
                if (typeof WeixinJSBridge == "undefined"){
                    if( document.addEventListener ){
                        document.addEventListener('WeixinJSBridgeReady', startPay(orderNumber), false);
                    }else if (document.attachEvent){
                        document.attachEvent('WeixinJSBridgeReady', startPay(orderNumber));
                        document.attachEvent('onWeixinJSBridgeReady', startPay(orderNumber));
                    }
                }else{
                    startPay(orderNumber);
                }
                App.hideLoading();
            },1000);
        }

        function targetPage(){
            WeixinJSBridge.call('closeWindow');
        }

    </script>














































